<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modeling</title>
<?php echo importCSS("template.css|style.css|contractor-single.css|font.css");?>
<?php echo importJS("jquery.min.js");?>
</head>
<body>
<?php echo L('LANG_FONT');?>
<script> var THEME_ROOT = '__ROOT__/themes/' ; </script>
<div class="header clearfix">
	<div class="center">
    	<a href="<?php echo U('/index');?>"><div class="logo">
        	<img src="__ROOT__/themes/images/logo.png" />
        </div></a>
        <div class="menu">
        	<a href="<?php echo U('/work/index');?>" <?php echo ($nav_menu=="work"?" class='now'":"");?>><div><?php echo L('HEADER_WORK');?></div></a> <!-- class="now"-->
            <a href="<?php echo U('/contractor/index');?>" <?php echo ($nav_menu=="contractor"?" class='now'":"");?>><div><?php echo L('HEADER_CONTRACTOR');?></div></a>
            <a href="<?php echo U('/space/index');?>" <?php echo ($nav_menu=="space"?" class='now'":"");?>><div><?php echo L('HEADER_MY_SPACE');?></div></a>
        </div>
        <div class="search">
        	<div><img src="__ROOT__/themes/images/search.png" /></div>
        	<form method="get" action="<?php echo U('/work/index');?>" >
            <input type="text" id="search" name="name" value="<?php echo L('HEADER_SEARCH');?>" onfocus="if(value=='<?php echo L('HEADER_SEARCH');?>') {value=''} setStyleOne(this.id)" onblur="if (value=='') { value='<?php echo L('HEADER_SEARCH');?>' } setStyleTwo(this.id)"/>
            </form>
        </div>
        <?php if ($_cUser) { ?>
        <div class="signafter">
        	<a href="<?php echo U('/signout');?>"><div  class="outbutton"><?php echo L('HEADER_SIGN_OUT');?></div></a>
        	<a href="<?php echo U('/space/index');?>"><div class="word"><?php echo ($_cUser["username"]); ?></div></a>
        </div>
        <?php } else { ?>
        <div class="sign">
        	<a href="<?php echo U('/join');?>"><div><?php echo L('HEADER_JOIN');?></div></a>
            <a href="<?php echo U('/signin');?>"><div><?php echo L('HEADER_SIGN_IN');?></div></a>
        </div>
        <?php } ?>
    </div>
</div>
<div class="clear"></div>

<div class="main center clearfix">
    	<div class="inforbox">
    	<div class="conpic"><div style="height:100px;width:100px;overflow:hidden"><img src="<?php echo getAvatar($profile);?>" width=100 /></div></div>
        <div class="bliefbox">
       		<div class="conname"><span class="strong"><?php echo ($profile["username"]); ?></span></div>
            <div class="counword"><span class="strong"><?php echo M("country")->getFieldByCode($profile['country'],L('COUNTRY_LANG'));?></span></div>
            <span ID="followStatus">
           		<?php echo followStatus($_cUser,$profile['id']);?>
        	</span>
        	<script>
        		function follow_func(url) {
        			$.getJSON(url,function(data) {
        			//	console.log(data);
        				if (data.error > 0) {
        					alert(data.msg);
        				} else {
        					$("#followStatus").html(data.data); 
        				}
        			})
        		}
        		$(".action_follow").live("click",function() {
        			follow_func("<?php echo U('/contractor/follow/add/'.$profile['id']);?>");
        		});
        		$(".action_cancel").live("click",function() {
        			follow_func("<?php echo U('/contractor/follow/cancel/'.$profile['id']);?>");
        		});
        	</script>
            <div class="clear"></div>
    		<div class="aut">
    			<?php if(($profile["isverify"]) == "4"): ?><div class="autpic"><img src="__ROOT__/themes/images/vendor-acc.png" /></div>
            	<div class="autname"><?php echo h(xserialize($profile['verifyinfo'],'realname'));?></div>
            	<div class="autcountry"> (<?php echo h(xserialize($profile['verifyinfo'],'country'));?>)</div><?php endif; ?>
        	</div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div class="buttonbox">
    	<div class="button now infor"><?php echo L('CONTRACTOR_INFORMATION');?></div>
        <a href="<?php echo U('/contractor/works/'.$profile['id']);?>"><div class="button works"><?php echo L('CONTRACTOR_WORKS');?></div></a>
        <a href="<?php echo U('/contractor/cases/'.$profile['id']);?>"><div class="button cases"><?php echo L('CONTRACTOR_CASES');?></div></a>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div class="inforbox">
        <div class="clear"></div>
        <div class="skill">
        	<div class="skill-title"><?php echo L('CONTRACTOR_SKILLS');?> :</div>
        	<div id="skill_view"></div>
        	<input type="hidden" id="skill_data" value="<?php echo ($profile["userskill"]); ?>" />
        	<style>
	#skill_view .button{
		float:left;
		width:auto;
		margin:0px 5px 0px 0px;
	}
	.skillediotr {
		display:none;
	}
	.com .skillediotr {
		display:block;
	}
	.skillediotr .list,.skillediotr .action {
		margin:5px 0px;
	}
	.skillediotr .list .del {
		float:right;
	}
	.skillediotr .action input {
		float:left;
		width:200px;
	}
	.skillediotr .action .button {
		margin:2px 10px;
		float:left;
		width:50px;
		text-align:center
	}
</style>
<div class="skillediotr">
	<div class="list">
		<!--<div class="button"><span>ABC</span> <a href="#" class="del">x</a></div>
		<div class="button"><span>ABC</span> <a href="#" class="del">x</a></div>
		<div class="button"><span>ABC</span> <a href="#" class="del">x</a></div>-->
	</div>
	<div class="action">
		<input type="text" id="new_skill" value="" onfocus="setStyleOne(this.id)" onblur="setStyleTwo(this.id)" />
		<div class="button"><?php echo L('EDITOR_ADD');?></div>
	</div>
</div>

<script>
	$now_skill = $("#skill_data").val().split(',');
	$skill_edit_html = "";
	$skill_html = "";
	for (var si=0;si<$now_skill.length-1;si++) {
		$skill_edit_html += '<div class="button"><span>'+$now_skill[si]+'</span> <a href="javascriot:void(0)" class="del">x</a></div>';
		$skill_html += '<div class="button">'+$now_skill[si]+'</div>';
	}
	$("#skill_view").html($skill_html);
	$(".skillediotr .list").html($skill_edit_html);

	function update_skill(){
		var $new_val = "";
		$(".skillediotr .list .button span").each(function(){
			$new_val += $(this).text()+",";
		});
		$("#skill_data").val($new_val);
		//console.log($new_val);
	}
	$(".skillediotr .list .del").live("click",function() {
		$(this).parent().remove();
		update_skill();
	});
	
	$(".skillediotr .action .button").click(function() {
		$newval = $("#new_skill").val().trim();
		if ($newval) {
			$canadd = true;
			$(".skillediotr .list .button span").each(function(){
				if ($(this).text() == $newval) {
					alert("Duplicate value");
					$canadd = false;
				}
			});
			if ($canadd) {
				$(".skillediotr .list").append('<div class="button"><span>'+$newval+'</span> <a href="javascriot:void(0)" class="del">x</a></div>');
				$("#new_skill").val("");
			}
			update_skill();
		}
	});
	
</script>
        </div>
        <div class="clear"></div>
        <div class="border"></div>
        <div class="clear"></div>
        <div class="favorite"><?php echo L('CONTRACTOR_FEEDBACK_RATE');?> : <span class="strong"><?php echo ($profile["remark"]); ?>%</span></div>
        <div class="clear"></div>
        <div class="profile"><?php echo L('CONTRACTOR_PROFILE_INTEGRITY');?> : <span class="strong">90%</span></div>
        <div class="clear"></div>
        <div class="acquire"><?php echo L('CONTRACTOR_NUMBER_OF_PROJECTS_ACQUIRED');?> : <span class="strong"><?php echo countAcq($profile['id']);?></span></div>
        <div class="clear"></div>
		<div class="cases"><?php echo L('CONTRACTOR_CASES_UPLOADED');?> : <span class="strong"><?php echo countCase($profile['id']);?></span></div>
        <div class="clear"></div>
        <div class="cases"> <?php echo L('CONTRACTOR_TOTAL_REVENUE');?> : <span class="strong"><?php echo ($profile["revenue"]); ?></span></div>
        <div class="clear"></div>
        <div class="intro">
        	<div class="intro-title"><?php echo L('CONTRACTOR_INTRODUCTION');?> :</div>
            <div class="intro-word"><?php echo (h($profile["intro"])); ?></div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<div class="clear"></div>

<div class="footer">

</div>
<?php echo importJS("downlist.js|input.js|signup.js");?>
</body>
</html>